package library.and.xps.com.step.view.activity;

import android.view.View;
import android.view.ViewTreeObserver;
import android.widget.ImageView;
import android.widget.TextView;

import library.and.xps.com.step.R;
import library.and.xps.com.step.util.BitmapUtil;
import library.and.xps.com.step.util.TeamHelper;
import library.and.xps.com.step.view.base.BaseActivity;

public class InviteActivity extends BaseActivity {
    ImageView iv_arcode;

    @Override
    protected int getLayout() {
        return R.layout.activity_invite;
    }

    @Override
    protected void setData() {
        if (!TeamHelper.getIns().hasTeam()) return;

        ViewTreeObserver observer = iv_arcode.getViewTreeObserver();
        observer.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
            @Override
            public void onGlobalLayout() {
                iv_arcode.getViewTreeObserver().removeGlobalOnLayoutListener(this);
                iv_arcode.setImageBitmap(BitmapUtil.create2DCoderBitmap(TeamHelper.getIns().getTid(), iv_arcode.getMeasuredWidth(), iv_arcode.getMeasuredHeight()));
            }
        });
    }

    @Override
    protected void init() {
        iv_arcode = r2v(R.id.iv_arcode);
        ((TextView)r2v(R.id.actionbar_tv_title)).setText("邀请");
        r2v(R.id.actionbar_iv_back).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }
}
